package com.match.controller;

import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.match.model.MatchPoolPlayerInfo;
import com.match.task.MatchProcessor;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value = "/playerAction")
@Api(value = "玩家管理", description = "玩家一直在线程当中待匹配")
public class PlayerController {

    @RequestMapping(value = "/addPlayer", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "投放玩家")
    public String putPlayerIntoMatchPool(@ModelAttribute MatchPoolPlayerInfo matchPoolPlayerInfo) {
        MatchProcessor.putPlayerIntoMatchPool(matchPoolPlayerInfo.getPlayerId(),
                matchPoolPlayerInfo.getRank());
        return "success";
    }

    @RequestMapping(value = "/countPlayer", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "计算在匹配的游戏玩家数量")
    public String countPoolplayer() {
        return MatchProcessor.countPoolplayer() + "";
    }
}
